
<style type="text/css">
    #calendar .header {
        width: 966px;
        height: 40px;
        margin-bottom: 10px;

    }

    #calendar .weeks {
        border-bottom: 1px solid #ccc;
        width: 966px;
        height: 40px;
        line-height: 40px;
        background: #f2f2f2;
    }

    #calendar .weeks .col-sm-2 {
        width: 138px;
        font-weight: bold;
        text-align: center;
    }

    #calendar .dates {
        width: 966px;
        height: 138px;
        text-align: center;

    }

    #calendar .dates .col-sm-2 {
        position: relative;
        width: 138px;
        height: 138px;
        text-align: center;
        background: #fefefe;
        line-height: 130px;
        border: 1px solid #f2f2f2;
    }


    #calendar .dates .col-sm-2 .btn {
        margin: 0;

        color:#fff;
        overflow: hidden;

        -ms-word-break: break-all;
        word-break: break-all;
        word-wrap: break-word;
        white-space:normal;

        max-height:50px;
        background:#f2f2f2;
        color:#333;

    }
    #calendar .dates .col-sm-2 .btn.btn-set-has {
        background: #00aeff;
        color:#fff;
    }
    #calendar .dates .col-sm-2 .date{
        position:absolute;
        right:0;top:5px;
        font-size:14px;
        color:#999;
        line-height:20px;
        display:inline-block;width:20px;height:20px;
    }
    #calendar .dates .col-sm-2 .link{
        position:absolute;
        right:0;bottom:5px;
        font-size:14px;
        color:#666;
        line-height:20px;
        text-align: center;
        display:inline-block;width:138px;height:20px;
    }

    #loading {
        width:100%;
        padding:20px 0;
        text-align: center;;
    }

    #calendar .dates .col-sm-2.select {
        /*background:#fefdeb;*/
    }
    #calendar .dates .col-sm-2 a {
        color:#666;
    }
</style>
<div class="row">
	<div class="alert alert-success alert-dismissable">
		<i class="fa fa-bullhorn alert-link"></i>[温馨提示]：{help}
	</div>
    <div class="col-sm-12">
        <div id="calendar">
            <div class="header">
               <div class="input-group">
						<div> 
                            <select class="form-control" style="width:100px;display:inline-block;" ng-model="pagedata.currentyear" ng-change="pagedata.getDates();" id="year">  
                                <option  ng-repeat="y in pagedata.years" value="{{y}}"  ng-select="pagedata.currentyear==y">{{y}}</option>
                            </select>
                            <select class="form-control" style="width:100px;display:inline-block;" ng-model="pagedata.currentmonth" ng-change="pagedata.getDates();" id="month"> 
                                <option ng-repeat="m in  pagedata.months" value="{{m}}"  ng-select="pagedata.currentmonth==m" >{{m}}</option>
                            </select>
							<a href="javascript:;" ng-click="pagedata.batch_set()" class="btn btn-default btn-sm btn-batch-set" style="display:inline-block;margin:1px 15px">批量清空设置</a>
                        </div>
                        
                </div>
            </div>
            <div class="weeks">
                <div class="col-sm-2">日</div>
                <div class="col-sm-2">一</div>
                <div class="col-sm-2">二</div>
                <div class="col-sm-2">三</div>
                <div class="col-sm-2">四</div>
                <div class="col-sm-2">五</div>
                <div class="col-sm-2">六</div>
            </div>
            <div id="loading"><i class="fa fa-spinner fa-spin"></i> 正在加载数据</div>
			<div class="dates">
				<div ng-repeat="item in pagedata.kongday" class="col-sm-2 date-item ">
					<div class="date"></div>
					<a>
						<div>
						空
						</div>
					</a>
				</div>
				<div ng-repeat="(k,value) in pagedata.calendar" class="col-sm-2 date-item " ng-class="{'select':{tovalue}.{name}.indexOf(';'+value+';')>=0}" date="{{k}}">
					<div ng-if="k<10" class="date">0{{k}}</div>
					<div ng-if="k>=10" class="date">{{k}}</div>
					<a href="javascript:;" ng-click="duoxuans(value,{tovalue},'{name}')" class="btn btn-set" ng-class="{'btn-set-has':{tovalue}.{name}.indexOf(';'+value+';')>=0}" >
						<div>
						{{{tovalue}.{name}.indexOf(';'+value+';')>=0?'已选择':'未选择'}}
						</div>
					</a>
				</div>
			</div>
        </div>
    </div>
</div>
<script language="javascript">
scope.pagedata.currentyear='';
scope.pagedata.currentmonth='';
scope.pagedata.getDates=function(){
		scope.get('core/tools.get_data/time_days/year='+scope.pagedata.currentyear+'&month='+scope.pagedata.currentmonth,function(res){
			console.log('getDates');
			scope.pagedata.years=res.years;
			scope.pagedata.months=res.months;
			scope.pagedata.kongday=res.kongday;
			scope.pagedata.calendar=res.calendar;
			scope.pagedata.currentyear=res.year;
			scope.pagedata.currentmonth=res.month;
			$('#loading').hide();
			scope.$evalAsync();
		});
}
scope.pagedata.getDates();
bindHover();
function bindHover(){
        $('.date-item').unbind('mouseover').mouseover(function(){
            if( $(this).attr('storeid')){
                $(this).find('.link').show();
            }else{
                $(this).find('.link').hide();
            }
        }).unbind('mouseout').mouseout(function(){
            $(this).find('.link').hide();

        })
}
scope.pagedata.batch_set=function(k){
	scope.confirm({
				'message':'确认要清空数据吗？',
				'success':function(){
					scope.{tovalue}.{name}=''; 
					scope.$evalAsync();
				}
	});
}
</script>
